package com.jerry.base.io.base64;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Base64;

/**
 * Created with IntelliJ IDEA
 * User: Jerry
 * Date: 2024/1/28
 * Time: 12:02
 * Description:
 */
@Slf4j
public class Base64Usage {

    @Test
    public void read() throws IOException {
        String filePath = "src/main/resources/io/girl.jpg";

        Base64.Encoder encoder = Base64.getEncoder();
        FileInputStream fileInputStream = new FileInputStream(filePath);

        String encoded = encoder.encodeToString(fileInputStream.readAllBytes());
        log.info("base64后：{}" , encoded);
    }
}
